package org.cshoo.sys.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import mx.collections.ArrayCollection;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	import org.cshoo.sys.business.RoleDelegate;
	import org.cshoo.sys.event.FindRoleListEvent;
	import org.cshoo.sys.model.vo.Role;
	import org.cshoo.sys.model.SysModelLocator;
	
	public class FindRoleListCommand implements ICommand, IResponder
	{
		private var _model:SysModelLocator = SysModelLocator.getInstance();	
		public function execute(event:CairngormEvent):void
		{
			var role:Role = (event as FindRoleListEvent).role;
			var roleDelegate:RoleDelegate = new RoleDelegate(this);
			roleDelegate.findRoleList(role);
		}
		
		public function result(event:Object):void
		{
			var collection:ArrayCollection = (event as ResultEvent).result as ArrayCollection;
			_model.roleCollection = collection;
		}
		
		public function fault(info:Object):void
		{
			Alert.show("无法连接");
		}
	}
}